$(function() {
	// 增加
	$('#addActivitiModeler').on('click', function() {
		window.location.href = "/mcode/activiti/create";
	});

	// 删除
	$('#activitiDataTableId tbody').on('click', '#deleteActivitiModel',
			function() {
				var id = $(this).attr('data-id');
				confirm("您确定要删除此条信息吗 ?", function(isConfirm) {
					if (isConfirm) {
						$.post("/mcode/activiti/delete", {
							id : id
						}, function(data) {
							if (data) {
								activitiDataTable.ajax.reload();
								swal("成功", "操作成功", "success");
							} else {
								swal("失败", "操作失败", "error");
							}
						});
					} else {
						swal("取消", "您的操作已取消", "error");
					}
				});
			});

	// 修改
	$('#activitiDataTableId tbody').on('click', '#updateActivitiModel',
			function() {
				var id = $(this).attr('data-id');
				window.location.href = "/mcode/activiti/modify?id=" + id;
			});

	// 部署
	$('#activitiDataTableId tbody').on('click', '#deployActivitiModel',
			function() {
				var id = $(this).attr('data-id');
				confirm("您确定要部署此模板吗?", function(isConfirm) {
					if (isConfirm) {
						$.post("/mcode/activiti/deploy", {
							id : id
						}, function(data) {
							if (data.flag == '0') {
								activitiDataTable.ajax.reload();
								swal("成功", "操作成功", "success");
							} else if (data.flag == '1') {
								swal("失败", "请不要部署空模板！！！", "error");
							} else {
								swal("失败", "操作失败", "error");
							}
						});
					} else {
						swal("取消", "您的操作已取消", "error");
					}
				});
			});
});